<template>
    <div class="patent-box">
        <van-pull-refresh v-model="pullLoading" @refresh="onRefresh">
            <van-list
                v-model="loading"
                :finished="finished"
                finished-text="没有更多数据"
                :immediate-check="false"
                @load="onLoad"
                >
                <template slot="default">
                    <!-- order展示模块 -->
                    <orderShowTemplate 
						v-for="data in patentList"
						:key="data.id" 
						:dataList="data"
						:describe="true"
                        :fieldList="[{ message: `订单编号：${data.order_number}`}, { message: `创建时间：${data.created_at}` }]"
                        :type="'name'"
						@onTitle="$router.push(`/user/details3/${data.id}`)">
					</orderShowTemplate>
                </template>
            </van-list>  
        </van-pull-refresh>
    </div>
</template>

<script>
import orderShowTemplate from '~/components/_orderShowTmp'
export default {
    data() {
        return {
            patentList: [],
            loading: false,
            pullLoading: false,
            page: 1,
            finished: false,
        }
    },
    created() {
        this.getOrderList()
    },
    methods: {
        getOrderList() {
            this.page = 1
            this.$axios.get('/api/consumer/patent', { params: {
                page: 1
            } }).then(res => {
                if(res.status === 200) {
                    if(res.data.page.total <= 15) {
                        this.finished = true
                    }else{
                        this.finished = false
                    }
                    this.patentList = res.data.data
                    this.pullLoading = false
                }else{
                    that.$toast('请求错误');
                }
            })
        },
        onLoad() {
            setTimeout(() => {
                this.$axios.get('/api/consumer/patent', { params: {
                    page: this.page + 1
                } }).then(res => {
                    if(res.data.data.length > 0) {
                        this.page++
                        this.patentList.push(...res.data.data)
                        this.loading = false
                    }else{
                        this.loading = false
                        this.finished = true
                    }
                })
            }, 500);
        },
        onRefresh() {
            setTimeout(() => {
                this.getOrderList()
            }, 500)
        }
    },
    components: {
        orderShowTemplate
    }
}
</script>

<style lang="less" scoped>
    .patent-box{
        
    }
</style>